/*	Date:2017/7/29
 *	Author: Chunsheng Chen
 *	功能： 解释抽象语法树
 */
#ifndef _CM_INTERPRET_H_
#define _CM_INTERPRET_H_

#include"absyn.h"
#include"env.h"
#include"type.h"
#include"table.h"



struct exptype{
	struct CM_exp* exp;
	struct valtype* vty;
};

struct stmttype{
	enum { stmt_exp, stmt_list, stmt_decl, stmt_assign, stmt_if, stmt_while, stmt_for, stmt_return } kind;
	struct exptype* et;
};

struct exptype* newExpType(struct CM_exp*, struct valtype*);

struct stmttype* newStmtType(int, struct exptype*);

struct exptype* interexp(struct table*, struct table*, struct CM_exp*);

struct valtype* calcExp(int, struct exptype*, struct exptype*);

void interdecl(struct table*, struct table*, struct CM_decl*);

struct stmttype* interstmt(struct table*, struct table*, struct CM_stmt*);

struct stmttype* interstmtlist(struct table*, struct table*, struct CM_stmtlist*);

void interdecl(struct table*, struct table*, struct CM_decl*);

void intertypedecl(struct table*, struct table*, struct CM_typedecl*);

void intervardecl(struct table*, struct table*, struct CM_vardecl*);

void interfundecl(struct table*, struct table*, struct CM_fundecl*);

struct exptype* interassign(struct table*, struct table*, struct CM_assign*);

struct valtype* intervar(struct table*, struct table*, struct CM_var*);

struct valtype* inter_id_var(struct table*, struct table*, struct symbol*);

struct valtype* inter_array_get_var(struct table*, struct table*, struct CM_arr_get*);

struct valtype* inter_struct_get_var(struct table*, struct table*, struct CM_struct_get*);

void showStmtValue(struct table*, struct table*, struct stmttype*);

struct valtype* interfuncall(struct table*, struct table*, struct CM_fun_call*);

#endif
